home *** CD-ROM | disk | FTP | other *** search
- Path: news.lpr.carel.fi!usenet
- From: Ari Lukumies <aril@cmt.lpr.mail.carel.fi>
- Newsgroups: comp.lang.c
- Subject: Re: inserting assembly code in C?
- Date: Thu, 01 Feb 1996 11:20:05 +0200
- Organization: Carelcomp Forest
- Message-ID: <311085C5.4EBD@cmt.lpr.mail.carel.fi>
- References: <4emsvo$lq4@linet02.li.net> <310FCC47.6A4@setsk0.rpi.ses.alcatel.es>
- NNTP-Posting-Host: renoir.cclahti.carel.fi
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0b6a (WinNT; I)
-
- 1570sw wrote:
- >
- > Don Matthews wrote:
- > >
- > > I'm using Borland C compiler and I'd like to know how I would go about
- > > inserting some assembly code into my C programs.
- > >
- > > Thanks...
- >
- > Hi!
- >
- > You have tow ways:
- >
- > Use the C instruction inline or put your .asm files in the project file.
-
- Actually, inline just tells C compiler to inline the function (ie. place the function's
- code at the place there would normally be code to call the function) if the compiler
- finds it worthy (usually only when the function contains very few lines and speed
- optimizations are used). The easiest way to include assembly code is to use the keyword
- __asm:
-
- __asm mov ax,0xfe /* One line of asm code */
- __asm { /* Multiple asm code lines */
- mov ax,0xfe
- mov bx,ax
- }
-
- Also note that if you use jumps (jmp x), you'll have to define the label outside the
- assembly code:
-
- __asm {
- mov ax,0xfe
- jmp label
- }
- label:
- __asm {
- /* Other stuff */
- }
-
- Later,
- AriL
- --
- All my opinions are mine and mine alone.
-